/**
 * Created by evantang on 2018/6/4.
 */
import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {DOMAIN_SERVER_URL} from "../constants";
import {Observable} from "rxjs";
import {User} from "../entity/User";
import {RestResult} from "../entity/rest-result";
import {BaseService} from "./baseService";

@Injectable()
export class SMSService extends BaseService<User> {

  constructor(http: HttpClient) {
    super(http);
  }

  getServiceUrl(): string {
    return DOMAIN_SERVER_URL ;
  }

  getSMSCode(phone: string): Observable<any> {
    return this.http.get<RestResult<any>>(this.getServiceUrl() + "/windbell/sms"+ `?phone=${phone}` ).map((res)=>{
      return res.value
    })
  }
  verifySMSCode(phone: string,code: string): Observable<any> {
    return this.http.get<RestResult<any>>(this.getServiceUrl() + "/windbell/smsverify"+ `?phone=${phone}&code=${code}` ).map((res)=>{
      return res.value
    })
  }

}
